package com.PlantVsZombies.online;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;

import com.PlantVsZombies.constant.GameVariable;

public class DataTransfer {
	
	private Socket socket;
	private Thread t;
	
	public DataTransfer(Socket socket, Thread t) {
		super();
		GameVariable.isConnected = true;
		this.socket = socket;
		this.t = t;
	}
	
	/**
	 * 发送对象
	 * @param zombies
	 */
	public void sendObjData(Object object) {
		ObjectOutputStream oos = null;
		try {
			oos = new ObjectOutputStream(socket.getOutputStream());
			oos.writeObject(object);
			oos.flush();
		} catch (IOException e) {
			System.out.println("发送数据时发生错误!");
			e.printStackTrace();
		} finally {
			/*try {
				oos.close();
			} catch (IOException e) {
				System.out.println("关闭流发生错误");
				e.printStackTrace();
			}*/
		}
	}
}
